package com.mandao.concurrency.interviewset.backdemo;

import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

/**
 * Description
 *
 * @author woniu
 * @date 2019/6/29 11:57
 */
public class MainClass {

    /**
     * @param args
     */
    public static void main(String[] args) {

        //产生四个普通窗口
        for(int i=1; i<5 ;i++){
            ServiceWindow commonWindow = new ServiceWindow();
            commonWindow.setWindowId(i);
            commonWindow.start();
        }

        ServiceWindow expressWindow = new ServiceWindow();
        //设置客户类型VIP
        expressWindow.setType(CustomerType.VIP);
        expressWindow.start();

        ServiceWindow vipWindow = new ServiceWindow();
        //设置客户类型 快速
        vipWindow.setType(CustomerType.EXPRESS);
        vipWindow.start();

        Executors.newScheduledThreadPool(1).scheduleAtFixedRate(
                ()->{
                    Integer number = NumberMachine.getInstance().getCommonManager().generateNewManager();
                    System.out.println(number + "号普通客户等待服务");
                },
                0,
                Constants.Common_Customer_Interval_Time,
                TimeUnit.SECONDS);

        Executors.newScheduledThreadPool(1).scheduleAtFixedRate(
                new Runnable(){
                    public void run(){	//快速客户
                        Integer number = NumberMachine.getInstance().getExpressManager().generateNewManager();
                        System.out.println(number + "号快速客户等待服务");
                    }
                },
                0,
                Constants.Common_Customer_Interval_Time*2,
                TimeUnit.SECONDS);

        Executors.newScheduledThreadPool(1).scheduleAtFixedRate(
                new Runnable(){
                    public void run(){	//VIP客户
                        Integer number = NumberMachine.getInstance().getVipManager().generateNewManager();
                        System.out.println(number + "号VIP客户等待服务");
                    }
                },
                0,
                Constants.Common_Customer_Interval_Time*6,
                TimeUnit.SECONDS);

    }


}
